using System;
using System.Collections.Generic;
using System.Text;
using System.Web;

namespace ScottIsAFool.Common
{
    public class Translations
    {
        # region Main Declarations
        XmlFileReader fr;
        char[] c = { ',' };
        String filename;

        #endregion

        #region Constants
        // Section Names
        private const string LANGUAGE = "language";
        private const string GLOBAL = "global";
        private const string BUTTONS = "buttons";
        private const string ERRORS = "errors";
        private const string MAINWINDOW = "mainwindow";
        private const string OPTIONSWINDOW = "optionswindow";
        private const string SIDEBAR = "sidebar";
        private const string THANKS = "thanks";
        private const string EXAMPLES = "examples";
        // Language Section
        private const string MARKET = "market";
        private const string LANGUAGENAME = "languagename";
        private const string CREATEDBY = "createdby";
        private const string CREATORLINK = "creatorlink";
        // Global Section
        private const string EMBEDSTYLE = "embedstyle";
        private const string STYLES = "styles";
        private const string OPENLINK = "openlink";
        private const string INCLUDETITLE = "includetitle";
        private const string SETAUTOPLAY = "setautoplay";
        private const string YOUTUBERELATED = "youtuberelated";
        private const string FEEDBACK = "feedback";
        private const string BLOG = "blog";
        private const string TRANSPARENCY = "transparency";
        // Buttons Section
        private const string CLOSE = "close";
        private const string INSERT = "insert";
        private const string CANCEL = "cancel";
        private const string SAVE = "save";
        private const string ADD = "add";
        private const string DELETE = "delete";
        private const string APPLY = "apply";
        // Errors Section
        private const string INVALIDLINKREASONS = "invalidlinkreasons";
        private const string INVALIDLINK = "invalidlink";
        private const string TRYAGAIN = "tryagain";
        private const string NOURL = "nourl";
        private const string ERRORGETTINGVIDEO = "errorgettingvideo";
        // OptionsWindow Section
        private const string MAINTABTITLE = "maintabtitle";
        private const string LANGUAGETABTITLE = "languagetabtitle";
        private const string GROUPCODEOPTIONS = "groupcodeoptions";
        private const string NEWWINDOWTEXT = "newwindowtext";
        private const string GROUPWIDTH = "groupwidth";
        private const string WIDTHTEXT = "widthtext";
        private const string ENABLED = "enabled";
        private const string YESNO = "yesno";
        private const string GROUPPREVIEW = "grouppreview";
        private const string PREVIEW = "preview";
        private const string GROUPTITLE = "grouptitle";
        private const string VIDEOTITLE = "videotitle";
        private const string CHOOSELANGUAGE = "chooselanguage";
        private const string GROUPLANGUAGEOPTIONS = "grouplanguageoptions";
        private const string SELECTLANGUAGE = "selectlanguage";
        private const string PIXELS = "pixels";
        private const string THANKSTO = "thanksto";
        private const string CREATORNAME = "creatorname";
        // Sidebar Section
        private const string MARGINS = "margins";
        private const string MARGINOPTIONS = "marginoptions";
        private const string MARGINATTRIBUTES = "marginattributes";
        // MainWindow Section
        private const string VIDEOLINK = "videolink";
        private const string GROUPOPTIONS = "groupoptions";
        private const string ENABLEPREVIEW = "enablepreview";
        private const string NOVIDEOLOADED = "novideoloaded";
        private const string VIDEOSIZE = "videosize";
        private const string SELECTOPTION = "selectoption";
        // Thanks Section
        private const string TESTERS = "testers";
        // Repeats
        private const string TITLE = "title";
        private const string MAINTEXT = "maintext";
        #endregion

        public Translations(string XmlFile)
        {
            fr = new XmlFileReader(XmlFile);
            filename = XmlFile;
        }

        #region Language Section Properties
        public string LanguageName
        {
            get { return HttpUtility.HtmlDecode(fr.GetIniValue(LANGUAGE, LANGUAGENAME, "")); }
            set { fr.SetIniValue(LANGUAGE, LANGUAGENAME, HttpUtility.HtmlEncode(value)); }
        }

        public string LanguageMarket
        {
            get { return HttpUtility.HtmlDecode(fr.GetIniValue(LANGUAGE, MARKET, "")); }
            set { fr.SetIniValue(LANGUAGE, MARKET, HttpUtility.HtmlEncode(value)); }
        }

        public string LanguageCreatedBy
        {
            get { return HttpUtility.HtmlDecode(fr.GetIniValue(LANGUAGE, CREATEDBY, "")); }
            set { fr.SetIniValue(LANGUAGE, CREATEDBY, HttpUtility.HtmlEncode(value)); }
        }

        public string LanguageCreatorLink
        {
            get { return HttpUtility.HtmlDecode(fr.GetIniValue(LANGUAGE, CREATORLINK, "")); }
            set { fr.SetIniValue(LANGUAGE, CREATORLINK, HttpUtility.HtmlEncode(value)); }
        }
        #endregion

        #region Global Section Properties

        public string GlobalEmbedStyle
        {
            get { return HttpUtility.HtmlDecode(fr.GetIniValue(GLOBAL, EMBEDSTYLE, "")); }
            set { fr.SetIniValue(GLOBAL, EMBEDSTYLE, HttpUtility.HtmlEncode(value)); }
        }

        public string GlobalStyles
        {
            get { return HttpUtility.HtmlDecode(fr.GetIniValue(GLOBAL, STYLES, "")); }
            set { fr.SetIniValue(GLOBAL, STYLES, HttpUtility.HtmlEncode(value)); }
        }

        public string GlobalOpenLink
        {
            get { return HttpUtility.HtmlDecode(fr.GetIniValue(GLOBAL, OPENLINK, "")); }
            set { fr.SetIniValue(GLOBAL, OPENLINK, HttpUtility.HtmlEncode(value)); }
        }

        public string GlobalIncludeTitle
        {
            get { return HttpUtility.HtmlDecode(fr.GetIniValue(GLOBAL, INCLUDETITLE, "")); }
            set { fr.SetIniValue(GLOBAL, INCLUDETITLE, HttpUtility.HtmlEncode(value)); }
        }

        public string GlobalSetAutoplay
        {
            get { return HttpUtility.HtmlDecode(fr.GetIniValue(GLOBAL, SETAUTOPLAY, "")); }
            set { fr.SetIniValue(GLOBAL, SETAUTOPLAY, HttpUtility.HtmlEncode(value)); }
        }

        public string GlobalYouTubeRelated
        {
            get { return HttpUtility.HtmlDecode(fr.GetIniValue(GLOBAL, YOUTUBERELATED, "")); }
            set { fr.SetIniValue(GLOBAL, YOUTUBERELATED, HttpUtility.HtmlEncode(value)); }
        }

        public string GlobalFeedback
        {
            get { return HttpUtility.HtmlDecode(fr.GetIniValue(GLOBAL, FEEDBACK, "")); }
            set { fr.SetIniValue(GLOBAL, FEEDBACK, HttpUtility.HtmlEncode(value)); }
        }

        public string GlobalBlog
        {
            get { return HttpUtility.HtmlDecode(fr.GetIniValue(GLOBAL, BLOG, "")); }
            set { fr.SetIniValue(GLOBAL, BLOG, HttpUtility.HtmlEncode(value)); }
        }

        public string GlobalTransparency
        {
            get { return HttpUtility.HtmlDecode(fr.GetIniValue(GLOBAL, TRANSPARENCY, "")); }
            set { fr.SetIniValue(GLOBAL, TRANSPARENCY, HttpUtility.HtmlEncode(value)); }
        }
        #endregion

        #region Buttons Section Properties

        public string ButtonClose
        {
            get { return HttpUtility.HtmlDecode(fr.GetIniValue(BUTTONS, CLOSE, "")); }
            set { fr.SetIniValue(BUTTONS, CLOSE, HttpUtility.HtmlEncode(value)); }
        }

        public string ButtonInsert
        {
            get { return HttpUtility.HtmlDecode(fr.GetIniValue(BUTTONS, INSERT, "")); }
            set { fr.SetIniValue(BUTTONS, INSERT, HttpUtility.HtmlEncode(value)); }
        }

        public string ButtonCancel
        {
            get { return HttpUtility.HtmlDecode(fr.GetIniValue(BUTTONS, CANCEL, "")); }
            set { fr.SetIniValue(BUTTONS, CANCEL, HttpUtility.HtmlEncode(value)); }
        }

        public string ButtonSave
        {
            get { return HttpUtility.HtmlDecode(fr.GetIniValue(BUTTONS, SAVE, "")); }
            set { fr.SetIniValue(BUTTONS, SAVE, HttpUtility.HtmlEncode(value)); }
        }

        public string ButtonAdd
        {
            get { return HttpUtility.HtmlDecode(fr.GetIniValue(BUTTONS, ADD, "")); }
            set { fr.SetIniValue(BUTTONS, ADD, HttpUtility.HtmlEncode(value)); }
        }

        public string ButtonDelete
        {
            get { return HttpUtility.HtmlDecode(fr.GetIniValue(BUTTONS, DELETE, "")); }
            set { fr.SetIniValue(BUTTONS, DELETE, HttpUtility.HtmlEncode(value)); }
        }

        public string ButtonApply
        {
            get { return HttpUtility.HtmlDecode(fr.GetIniValue(BUTTONS, APPLY, "")); }
            set { fr.SetIniValue(BUTTONS, APPLY, HttpUtility.HtmlEncode(value)); }
        }
        #endregion

        #region Errors Section Properties

        public string InvalidLinkReasons
        {
            get { return HttpUtility.HtmlDecode(fr.GetIniValue(ERRORS, INVALIDLINKREASONS, "")); }
            set { fr.SetIniValue(ERRORS, INVALIDLINKREASONS, HttpUtility.HtmlEncode(value)); }
        }
        #endregion

        #region  OptionsWindow Section Properties

        public string OptionsTitle
        {
            get { return HttpUtility.HtmlDecode(fr.GetIniValue(OPTIONSWINDOW, TITLE, "")); }
            set { fr.SetIniValue(OPTIONSWINDOW, TITLE, HttpUtility.HtmlEncode(value)); }
        }

        public string OptionsMainText
        {
            get { return HttpUtility.HtmlDecode(fr.GetIniValue(OPTIONSWINDOW, MAINTEXT, "")); }
            set { fr.SetIniValue(OPTIONSWINDOW, MAINTEXT, HttpUtility.HtmlEncode(value)); }
        }

        public string OptionsMainTabTitle
        {
            get { return HttpUtility.HtmlDecode(fr.GetIniValue(OPTIONSWINDOW, MAINTABTITLE, "")); }
            set { fr.SetIniValue(OPTIONSWINDOW, MAINTABTITLE, HttpUtility.HtmlEncode(value)); }
        }

        public string OptionsLanguageTabTitle
        {
            get { return HttpUtility.HtmlDecode(fr.GetIniValue(OPTIONSWINDOW, LANGUAGETABTITLE, "")); }
            set { fr.SetIniValue(OPTIONSWINDOW, LANGUAGETABTITLE, HttpUtility.HtmlEncode(value)); }
        }

        public string OptionsGroupCodeOptions
        {
            get { return HttpUtility.HtmlDecode(fr.GetIniValue(OPTIONSWINDOW, GROUPCODEOPTIONS, "")); }
            set { fr.SetIniValue(OPTIONSWINDOW, GROUPCODEOPTIONS, HttpUtility.HtmlEncode(value)); }
        }

        public string OptionsNewWindowText
        {
            get { return HttpUtility.HtmlDecode(fr.GetIniValue(OPTIONSWINDOW, NEWWINDOWTEXT, "")); }
            set { fr.SetIniValue(OPTIONSWINDOW, NEWWINDOWTEXT, HttpUtility.HtmlEncode(value)); }
        }

        public string OptionsGroupWidth
        {
            get { return HttpUtility.HtmlDecode(fr.GetIniValue(OPTIONSWINDOW, GROUPWIDTH, "")); }
            set { fr.SetIniValue(OPTIONSWINDOW, GROUPWIDTH, HttpUtility.HtmlEncode(value)); }
        }

        public string OptionsWidthText
        {
            get { return HttpUtility.HtmlDecode(fr.GetIniValue(OPTIONSWINDOW, WIDTHTEXT, "")); }
            set { fr.SetIniValue(OPTIONSWINDOW, WIDTHTEXT, HttpUtility.HtmlEncode(value)); }
        }

        public string OptionsEnabled
        {
            get { return HttpUtility.HtmlDecode(fr.GetIniValue(OPTIONSWINDOW, ENABLED, "")); }
            set { fr.SetIniValue(OPTIONSWINDOW, ENABLED, HttpUtility.HtmlEncode(value)); }
        }

        public string OptionsYesNo
        {
            get { return HttpUtility.HtmlDecode(fr.GetIniValue(OPTIONSWINDOW, YESNO, "")); }
            set { fr.SetIniValue(OPTIONSWINDOW, YESNO, HttpUtility.HtmlEncode(value)); }
        }

        public string OptionsGroupPreview
        {
            get { return HttpUtility.HtmlDecode(fr.GetIniValue(OPTIONSWINDOW, GROUPPREVIEW, "")); }
            set { fr.SetIniValue(OPTIONSWINDOW, GROUPPREVIEW, HttpUtility.HtmlEncode(value)); }
        }

        public string OptionsPreview
        {
            get { return HttpUtility.HtmlDecode(fr.GetIniValue(OPTIONSWINDOW, PREVIEW, "")); }
            set { fr.SetIniValue(OPTIONSWINDOW, PREVIEW, HttpUtility.HtmlEncode(value)); }
        }

        public string OptionsGroupTitle
        {
            get { return HttpUtility.HtmlDecode(fr.GetIniValue(OPTIONSWINDOW, GROUPTITLE, "")); }
            set { fr.SetIniValue(OPTIONSWINDOW, GROUPTITLE, HttpUtility.HtmlEncode(value)); }
        }

        public string OptionsVideoTitle
        {
            get { return HttpUtility.HtmlDecode(fr.GetIniValue(OPTIONSWINDOW, VIDEOTITLE, "")); }
            set { fr.SetIniValue(OPTIONSWINDOW, VIDEOTITLE, HttpUtility.HtmlEncode(value)); }
        }

        public string OptionsChooseLanguage
        {
            get { return HttpUtility.HtmlDecode(fr.GetIniValue(OPTIONSWINDOW, CHOOSELANGUAGE, "")); }
            set { fr.SetIniValue(OPTIONSWINDOW, CHOOSELANGUAGE, HttpUtility.HtmlEncode(value)); }
        }

        public string OptionsGroupLanguageOptions
        {
            get { return HttpUtility.HtmlDecode(fr.GetIniValue(OPTIONSWINDOW, GROUPLANGUAGEOPTIONS, "")); }
            set { fr.SetIniValue(OPTIONSWINDOW, GROUPLANGUAGEOPTIONS, HttpUtility.HtmlEncode(value)); }
        }

        public string OptionsThanksTo
        {
            get { return HttpUtility.HtmlDecode(fr.GetIniValue(OPTIONSWINDOW, THANKSTO, "")); }
            set { fr.SetIniValue(OPTIONSWINDOW, THANKSTO, HttpUtility.HtmlEncode(value)); }
        }

        public string OptionsSelectLanguage
        {
            get { return HttpUtility.HtmlDecode(fr.GetIniValue(OPTIONSWINDOW, SELECTLANGUAGE, "")); }
            set { fr.SetIniValue(OPTIONSWINDOW, SELECTLANGUAGE, HttpUtility.HtmlEncode(value)); }
        }

        public string OptionsPixels
        {
            get { return HttpUtility.HtmlDecode(fr.GetIniValue(OPTIONSWINDOW, PIXELS, "")); }
            set { fr.SetIniValue(OPTIONSWINDOW, PIXELS, HttpUtility.HtmlEncode(value)); }
        }

        public string OptionsCreator
        {
            get { return HttpUtility.HtmlDecode(fr.GetIniValue(OPTIONSWINDOW, CREATORNAME, "")); }
            set { fr.SetIniValue(OPTIONSWINDOW, CREATORNAME, HttpUtility.HtmlEncode(value)); }
        }

        #endregion

        #region Sidebar Section Properties

        public string SidebarMargins
        {
            get { return HttpUtility.HtmlDecode(fr.GetIniValue(SIDEBAR, MARGINS, "")); }
            set { fr.SetIniValue(SIDEBAR, MARGINS, HttpUtility.HtmlEncode(value)); }
        }

        public string SidebarMarginOptions
        {
            get { return HttpUtility.HtmlDecode(fr.GetIniValue(SIDEBAR, MARGINOPTIONS, "")); }
            set { fr.SetIniValue(SIDEBAR, MARGINOPTIONS, HttpUtility.HtmlEncode(value)); }
        }

        public string SidebarMarginAttributes
        {
            get { return HttpUtility.HtmlDecode(fr.GetIniValue(SIDEBAR, MARGINATTRIBUTES, "")); }
            set { fr.SetIniValue(SIDEBAR, MARGINATTRIBUTES, HttpUtility.HtmlEncode(value)); }
        }
        #endregion

        #region MainWindow Section Properties

        public string MainMainText
        {
            get { return HttpUtility.HtmlDecode(fr.GetIniValue(MAINWINDOW, MAINTEXT, "")); }
            set { fr.SetIniValue(MAINWINDOW, MAINTEXT, HttpUtility.HtmlEncode(value)); }
        }

        public string MainExamples
        {
            get { return HttpUtility.HtmlDecode(fr.GetIniValue(MAINWINDOW, EXAMPLES, "")); }
            set { fr.SetIniValue(MAINWINDOW, EXAMPLES, HttpUtility.HtmlEncode(value)); }
        }

        public string MainVideoLink
        {
            get { return HttpUtility.HtmlDecode(fr.GetIniValue(MAINWINDOW, VIDEOLINK, "")); }
            set { fr.SetIniValue(MAINWINDOW, VIDEOLINK, HttpUtility.HtmlEncode(value)); }
        }

        public string MainGroupOptions
        {
            get { return HttpUtility.HtmlDecode(fr.GetIniValue(MAINWINDOW, GROUPOPTIONS, "")); }
            set { fr.SetIniValue(MAINWINDOW, GROUPOPTIONS, HttpUtility.HtmlEncode(value)); }
        }

        public string MainEnablePreview
        {
            get { return HttpUtility.HtmlDecode(fr.GetIniValue(MAINWINDOW, ENABLEPREVIEW, "")); }
            set { fr.SetIniValue(MAINWINDOW, ENABLEPREVIEW, HttpUtility.HtmlEncode(value)); }
        }

        public string MainGroupPreview
        {
            get { return HttpUtility.HtmlDecode(fr.GetIniValue(MAINWINDOW, GROUPPREVIEW, "")); }
            set { fr.SetIniValue(MAINWINDOW, GROUPPREVIEW, HttpUtility.HtmlEncode(value)); }
        }

        public string MainNoVideoLoaded
        {
            get { return HttpUtility.HtmlDecode(fr.GetIniValue(MAINWINDOW, NOVIDEOLOADED, "")); }
            set { fr.SetIniValue(MAINWINDOW, NOVIDEOLOADED, HttpUtility.HtmlEncode(value)); }
        }

        public string MainVideoSize
        {
            get { return HttpUtility.HtmlDecode(fr.GetIniValue(MAINWINDOW, VIDEOSIZE, "")); }
            set { fr.SetIniValue(MAINWINDOW, VIDEOSIZE, HttpUtility.HtmlEncode(value)); }
        }

        public string MainSelectOption
        {
            get { return HttpUtility.HtmlDecode(fr.GetIniValue(MAINWINDOW, SELECTOPTION, "")); }
            set { fr.SetIniValue(MAINWINDOW, SELECTOPTION, HttpUtility.HtmlEncode(value)); }
        }
        #endregion

        #region Examples Section Properties

        public string ExamplesTitle
        {
            get { return HttpUtility.HtmlDecode(fr.GetIniValue(EXAMPLES, TITLE, "")); }
            set { fr.SetIniValue(EXAMPLES, TITLE, HttpUtility.HtmlEncode(value)); }
        }

        public string ExamplesMainText
        {
            get { return HttpUtility.HtmlDecode(fr.GetIniValue(EXAMPLES, MAINTEXT, "")); }
            set { fr.SetIniValue(EXAMPLES, MAINTEXT, HttpUtility.HtmlEncode(value)); }
        }
        #endregion

        #region ThanksTo Section Properties

        public string ThanksTitle
        {
            get { return HttpUtility.HtmlDecode(fr.GetIniValue(THANKS, TITLE, "")); }
            set { fr.SetIniValue(THANKS, TITLE, HttpUtility.HtmlEncode(value)); }
        }

        public string ThanksMainText
        {
            get { return HttpUtility.HtmlDecode(fr.GetIniValue(THANKS, MAINTEXT, "")); }
            set { fr.SetIniValue(THANKS, MAINTEXT, HttpUtility.HtmlEncode(value)); }
        }

        public string ThanksTesters
        {
            get { return HttpUtility.HtmlDecode(fr.GetIniValue(THANKS, TESTERS, "")); }
            set { fr.SetIniValue(THANKS, TESTERS, value); }
        }
        #endregion

        public void SaveTranslations()
        {
            fr.OutputFilename = filename;
            fr.Save();
        }

    }
}
